package com.magina.nety.config;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.UUID;
import lombok.extern.slf4j.Slf4j;
import org.assertj.core.util.Lists;
import org.redisson.api.RScoredSortedSet;
import org.redisson.api.RSortedSet;
import org.redisson.api.RedissonClient;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Configuration
@Slf4j
public class TestClassRedssion {

    @Resource
    private RedissonClient reportRedisson;

//    @Bean
    public Object testDemo01(){
        List<TestDemo> list = Lists.newArrayList();
        for (int i = 0; i < 55; i++) {
            TestDemo testDemo = TestDemo.builder().id(UUID.randomUUID().toString())
                    .date(DateUtil.format(new Date(),"yyyy-MM-dd"))
                    .name("test" + i).build();
            list.add(testDemo);
        }
        RSortedSet rSortedSet = reportRedisson.getSortedSet("test");
        rSortedSet.addAsync(list);
        RScoredSortedSet rScoredSortedSet = reportRedisson.getScoredSortedSet("test");
        log.info(rScoredSortedSet.toString());
        return rScoredSortedSet;
    }
}
